<h2><%=h _("Issues for me")%></h2>

<table id="queues">

<tr><td colspan="7"><h3><%=h _("Issues Created by me")%></h3></td></tr>

<% 
   issues = self.current_user.issues.find(:all, :order => 'updated_at desc')
   if issues.length == 0 %>
<tr><td colspan="7"><span class="disabled"><%=h _("(None)")%></td></tr>
<% else %>
<tr align="left">
  <th><%=h _("Id")%></th>
  <th><%=h _("Subject")%></th>
  <th><%=h _("Owner")%></th>
  <th><%=h _("Reviewers")%></th>

  <th><%=h _("Comments")%></th>
  <th><%=h _("Drafts (mine)")%></th>
  <th><%=h _("Last updated")%></th>
</tr>

<% issues.each {|i| %>
  <% draft = i.comments.count(:conditions => ['draft = 1 and comments.user_id = ?', (logged_in? ? 0 : self.current_user.id)]) %>
  <tr <%= draft > 0 ? 'style="color:red"' : '' %>>
    <td align="right"><div class="subject"><%= i.id %></td>
    <td><div class="subject">
	<%= link_to i.subject,{:controller => :issue, :action => :view, :id => i.id}, :class => "noul" %>
    </div></td>
    <td><div class="users"><%= (logged_in? && i.user_id == self.current_user.id) ? "me" : i.user.login %></div></td>
    <td><div class="users">
	<%=h i.reviewer_string %>
    </div></td>
    <td align="center">
      <%=h i.comment_count %>
    </td>
    <td align="center"><b><%= draft %></b></td>
    <td><div class="date"><%= timeago i.updated_at %></div></td>
  </tr>
<% } %>
<% end %>

<tr><td colspan="7"><h3><%=h _("Issues Reviewable by me")%></h3></td></tr>
<% 
   issues = self.current_user.reviews.find(:all, :conditions => ['closed = 0'], :order => 'updated_at desc')
   if issues.length == 0 %>
<tr><td colspan="7"><span class="disabled"><%=h _("(None)")%></td></tr>
<% else %>
<tr align="left">
  <th><%=h _("Id")%></th>
  <th><%=h _("Subject")%></th>
  <th><%=h _("Owner")%></th>
  <th><%=h _("Reviewers")%></th>

  <th><%=h _("Comments")%></th>
  <th><%=h _("Drafts (mine)")%></th>
  <th><%=h _("Last updated")%></th>
</tr>

<% issues.each {|i| %>
  <% draft = i.comments.count(:conditions => ['draft = 1 and comments.user_id = ?', (logged_in? ? 0 : self.current_user.id)]) %>
  <tr <%= draft > 0 ? 'style="color:red"' : '' %>>
    <td align="right"><div class="subject"><%= i.id %></td>
    <td><div class="subject">
	<%= link_to i.subject,{:controller => :issue, :action => :view, :id => i.id}, :class => "noul" %>
    </div></td>
    <td><div class="users">
	<%= (logged_in? && i.user_id == self.current_user.id) ? "me" : i.user.login %>
    </div></td>
    <td><div class="users">
	<%=h i.reviewer_string %>
    </div></td>
    <td align="center">
      <%=h i.comment_count %>
    </td>
    <td align="center"><b><%= draft %></b></td>
    <td><div class="date"><%= timeago i.updated_at %></div></td>
  </tr>
<% } %>
<% end %>

<tr><td colspan="7"><h3><%=h _("Issues Closed Recently")%></h3></td></tr>

<% 
   issues = self.current_user.reviews.find(:all, :conditions => ['closed = 1'], :order => 'updated_at desc')
   if issues.length == 0 %>
<tr><td colspan="7"><span class="disabled"><%=h _("(None)")%></td></tr>
<% else %>
<tr align="left">
  <th><%=h _("Id")%></th>
  <th><%=h _("Subject")%></th>
  <th><%=h _("Owner")%></th>
  <th><%=h _("Reviewers")%></th>

  <th><%=h _("Comments")%></th>
  <th><%=h _("Drafts (mine)")%></th>
  <th><%=h _("Last updated")%></th>
</tr>

<% issues.each {|i| %>
  <% draft = i.comments.count(:conditions => ['draft = 1 and comments.user_id = ?', (logged_in? ? 0 : self.current_user.id)]) %>
  <tr <%= draft > 0 ? 'style="color:red"' : '' %>>
    <td align="right"><div class="subject"><%= i.id %></td>
    <td><div class="subject">
	<%= link_to i.subject,{:controller => :issue, :action => :view, :id => i.id}, :class => "noul" %>
    </div></td>
    <td><div class="users"><%= (logged_in? && i.user_id == self.current_user.id) ? _("me") : i.user.login %></div></td>
    <td><div class="users">
	<%=h i.reviewer_string %>
    </div></td>
    <td align="center">
      <%=h i.comment_count %>
    </td>
    <td align="center"><b><%= draft %></b></td>
    <td><div class="date"><%= timeago i.updated_at %></div></td>
  </tr>
<% } %>
<% end %>

</table>
